package com.ruoyi.by.health.service.impl;

import com.ruoyi.by.health.domain.WechatLoginEmp;
import com.ruoyi.by.health.domain.entity.EmployeeMessageWall;
import com.ruoyi.by.health.domain.form.MessageWallForm;
import com.ruoyi.by.health.mapper.EmployeeMessageWallMapper;
import com.ruoyi.by.health.service.IEmployeeMessageWallService;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.system.service.ISysDeptService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;

import javax.validation.Validator;
import java.util.List;

/**
 * 用户 业务层处理
 *
 * @author ruoyi
 */
@Service
public class EmployeeMessageWallServiceImpl implements IEmployeeMessageWallService {
    private static final Logger log = LoggerFactory.getLogger(EmployeeMessageWallServiceImpl.class);
    @Autowired
    protected Validator validator;
    @Autowired
    private EmployeeMessageWallMapper employeeMessageWallMapper;
    @Autowired
    private ISysDeptService sysDeptService;

    @Override
    public List<EmployeeMessageWall> selectEmployeeGameScoreList(EmployeeMessageWall gameScore) {
        return employeeMessageWallMapper.selectEmployeeGameScoreList(gameScore);
    }

    @Override
    public int saveEmployeeMessage(EmployeeMessageWall employeeMessage, WechatLoginEmp loginEmp) {
        employeeMessage.setEmpId(loginEmp.getEmpId());
        employeeMessage.setDeptId(loginEmp.getDeptId());
        employeeMessage.setEmpName(loginEmp.getUsername());
        //employeeMessage.setEmpId(1L);
        SysDept sysDept = sysDeptService.selectDeptById(loginEmp.getDeptId());
        //SysDept sysDept= sysDeptService.selectDeptById(100L);
        employeeMessage.setDeptName(sysDept.getDeptName());
        return employeeMessageWallMapper.insertEmployeeGameScore(employeeMessage);
    }

    @Override
    public void auditMessage(MessageWallForm form) {
        Assert.notEmpty(form.getIdList(), "审批ID不能为空");
        employeeMessageWallMapper.auditMessage(form);
    }
}
